<template>
  <div class="badge">
    <span v-if="userWait > 0">用户等待：{{ format(userWait) }}</span>
    <span v-if="agentWait > 0">客服等待：{{ format(agentWait) }}</span>
  </div>
</template>

<script setup>
// 智能时间格式化（缓存结果）
const timeFormatCache = new Map();
const format = (seconds) => {
  if (!timeFormatCache.has(seconds)) {
    const mins = Math.floor(seconds / 60);
    timeFormatCache.set(seconds, mins > 60 
      ? `${Math.floor(mins/60)}h${mins%60}m` 
      : `${mins}m`);
  }
  return timeFormatCache.get(seconds);
};
</script>